<template>
	 <div class="ui-modal" role="dialog" v-el:modal>
     <div>
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">修改组别-{{item.name}}</h4>
          </div>
          <div class="modal-body">
            <input type="text" class="form-control" v-el:input :placeholder="holder">
          </div>
          <div class="modal-footer">
 						<v-button theme="primary" class="pull-left" @click="resolve">确认</v-button>
            <v-button @click="reject">取消</v-button>
          </div>
        </div><!-- /.modal-content -->
      </div>
     </div>
  </div>
</template>

<script>
export default {
		props: {
			item: {
				type: Object,
				default: function() {
					return {
						name:""
					}
				}
			}
		},
    methods: {
			  init() {
					$(this.$els.modal).modal('show');
				},
				hide() {
					$(this.$els.modal).modal('hide');
					this.$els.input.value = "";
				},
			  get() {
					return this.$els.input.value;
				},
				resolve() {
					let name = this.get();
					if(!name) {
						let alert = {
							title:"操作提示",
							content:"请填写组别名称"
						}
						Midway.alert(alert);
						return false;
					}
					if(name.length>10) {
						let alert = {
							title:"温馨提示",
							content:"组别名请控制在十个字以内"
						}
						Midway.alert(alert);
						return false;
					}
					let item = this.item;

					let data = {
						id: item.id.id,
						name: name,
						mchtIdFlag:item.id.mchtId
					}

					this.$post({
						data,
						url: '/api/v1' + projectName_Url + '/wechat/subGroup/upd.html'
					}).then(response => {
						let message = {
							title:"操作提示",
							content:"修改成功"
						}
						Midway.alert(message);
						item.name = name;
						this.hide();
					},error =>{})

				},
				reject() {
					this.hide();
				}

		},
		ready() {
					$(this.$els.modal).on('hidden.bs.modal', function () {
							$("body").css('padding-right','0px');
					})
		}
}
</script>
